#include <vector>
#include <iostream>

using namespace std;

//bool isOdd(int x)
//{
//	return x % 2 ? true : false;
//}


void reOrderArray(vector<int> &array) {
	vector<int>::iterator lastOdd;
	vector<int> even;
	for (vector<int>::iterator iter = array.begin();
		iter != array.end();)
	{
		if (*iter % 2)
		{
			lastOdd = iter;
			++iter;
		}
		else
		{
			even.push_back(*iter);
			iter = array.erase(iter);
		}
	}
	array.insert(++lastOdd, even.begin(), even.end());
}

void reOrderArray1(vector<int> &array) {
	vector<int>::iterator fOdd , fEven;
	fEven = array.begin();
	fOdd = --array.end();
	while(fOdd != fEven)
	{
		while (fOdd != fEven && (*fEven%2)) ++fEven;
		if (fOdd == fEven) return;
		//fOdd = fEven;
		while (!(*fOdd % 2) && fOdd != fEven) --fOdd;
		if (fOdd == fEven)
			return;
		int tmp = *fOdd;
		*fOdd = *fEven;
		*fEven = tmp;
		//++fEven;
		//++fOdd;
	}
}

void reOrderArray2(vector<int> &array)
{
	vector<int> odd, even;
	for (auto i : array)
	{
		if (i % 2)
			odd.push_back(i);
		else
			even.push_back(i);
	}

	array.clear();
	array.insert(array.begin(), odd.begin(), odd.end());
	array.insert(array.end(), even.begin(), even.end());

}

//int main()
//{
//	vector<int> v = {0,1,11,2,3,8,4,5,6};
//	reOrderArray(v);
//
//	return 0;
//}
